package com.niji.littly_donkey_android.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.makeramen.roundedimageview.RoundedImageView;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.bean.Comment;
import com.niji.littly_donkey_android.util.NetworkGlideImageLoader;

import java.util.ArrayList;
import java.util.List;

public class IndexChildCommentAdapter extends ArrayAdapter<Comment> {


    private static final String TAG = "IndexChildCommentAdapter";

    private Context context;

    public IndexChildCommentAdapter(Context context, ArrayList<Comment> members)
    {
        super(context,0, members);
        this.context = context;
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Comment comment = getItem(position);

        if(convertView == null)
        {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_index_child_comment, parent, false);
        }

        RoundedImageView roundedImageView = convertView.findViewById(R.id.index_child_comment_head);
        TextView commentTitle = convertView.findViewById(R.id.index_child_comment_nickname);
        TextView commentId = convertView.findViewById(R.id.index_child_comment_id);
        TextView commentMessage = convertView.findViewById(R.id.index_child_comment_content);
        TextView commentTime = convertView.findViewById(R.id.index_child_comment_time);
        //thumb.setImageBitmap(BitMap.getInstance().returnBitMap(u.getThumb()));
        NetworkGlideImageLoader.getInstance().displayImage((Activity) context,comment.getHead(),roundedImageView,34,34);
        commentTime.setText(comment.getTime());
        commentId.setText("" + comment.getId());
        commentMessage.setText(comment.getMessage());
        commentTitle.setText(comment.getTitle());
        return convertView;
    }

}



